package org.essilab.analyzer.application;

import java.io.BufferedOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import org.essilab.analyzer.Configuration.Config;
import org.essilab.analyzer.analyzer.db.Parser;

/**
 * This class is used to store the text file extraction of the XML dump in a
 * data base names "wiktionnary".
 *
 * @author Mohamed-Amine Chouchene, Ahcène Idinarere, Vincent Nock, Alain
 * Janin-Manificat
 */
public class ApplicationDao {

    /**
     * Parse the text files in the directory specified in savePath property
     * (config.ini). Stored informations a data base names "wiktionnary".
     */
    public static void main(String[] args) {
        try {
            PrintStream out = new PrintStream(new BufferedOutputStream(new FileOutputStream("out.err")));
            System.setErr(out);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        System.out.println("Start Main");
        long begin = System.currentTimeMillis();
        Config.setFile("config.ini");
        Parser.mainFolder = Config.get("savePath");
        Parser parser = new Parser();
        parser.parserAndSaveTerm();
         parser.parserAndSaveRelationTerm();
        long end = System.currentTimeMillis();
        System.out.println("End Main in " + (((float) (end - begin)) / 1000f) / 60 + " min");
    }
}
